home *** CD-ROM | disk | FTP | other *** search
/ Resource Library: Multimedia / Resource Library: Multimedia.iso / maestro / source / videoedt / vidbjcts.c < prev    next >
Encoding:
C/C++ Source or Header  |  1993-06-15  |  12.3 KB  |  560 lines

  1. /*
  2.  * Copyright (c) 1990, 1991, 1992 Stanford University
  3.  *
  4.  * Permission to use, copy, modify, and distribute this software and 
  5.  * its documentation for any purpose is hereby granted without fee, provided
  6.  * that (i) the above copyright notices and this permission notice appear in
  7.  * all copies of the software and related documentation, and (ii) the name
  8.  * Stanford may not be used in any advertising or publicity relating to
  9.  * the software without the specific, prior written permission of
  10.  * Stanford.
  11.  * 
  12.  * THE SOFTWARE IS PROVIDED "AS-IS" AND WITHOUT WARRANTY OF ANY KIND, 
  13.  * EXPRESS, IMPLIED OR OTHERWISE, INCLUDING WITHOUT LIMITATION, ANY 
  14.  * WARRANTY OF MERCHANTABILITY OR FITNESS FOR A PARTICULAR PURPOSE.  
  15.  *
  16.  * IN NO EVENT SHALL STANFORD BE LIABLE FOR ANY SPECIAL, INCIDENTAL,
  17.  * INDIRECT OR CONSEQUENTIAL DAMAGES OF ANY KIND, OR ANY DAMAGES
  18.  * WHATSOEVER RESULTING FROM LOSS OF USE, DATA OR PROFITS, WHETHER OR NOT
  19.  * ADVISED OF THE POSSIBILITY OF DAMAGE, AND ON ANY THEORY OF LIABILITY,
  20.  * ARISING OUT OF OR IN CONNECTION WITH THE USE OR PERFORMANCE OF THIS
  21.  * SOFTWARE.
  22.  */
  23.  
  24. /* $Header: /Source/Media/collab/VideoEdit/RCS/videoObjects.c,v 0.24 92/11/17 14:45:16 drapeau Exp Locker: drapeau $ */
  25. /* $Log:    videoObjects.c,v $
  26.  * Revision 0.24  92/11/17  14:45:16  drapeau
  27.  * Corrected errors in configuration of several players, especially the
  28.  * Pioneer4200 player.
  29.  * 
  30.  * Revision 0.23  92/09/04  17:03:30  drapeau
  31.  * Updated code to reflect changes in VideoObject.
  32.  * Also, modified code for better ANSI compliance.
  33.  * 
  34.  * Revision 1.14  92/09/03  10:25:12  drapeau
  35.  * Changed communications settings for the NEC driver configuration.
  36.  * 
  37.  * Revision 1.13  92/09/02  17:14:04  drapeau
  38.  * Modified device-specific Config structs to reflect the addition of a
  39.  * new field, "flowControl".
  40.  * 
  41.  * Revision 1.12  92/09/01  16:58:56  drapeau
  42.  * A couple of changes:
  43.  * * Updated copyright notice.
  44.  * * Updated default Config structures to reflect new methods added to the
  45.  *   VideoObject.
  46.  * * Cosmetic changes to make code easier to read.
  47.  * * Added function prototypes for better ANSI compliance.
  48.  * 
  49.  * Revision 1.11  92/07/30  15:15:57  drapeau
  50.  * Improved method for setting asynchronous read function.  The previous
  51.  * version, although designed to be independent of any window system or
  52.  * programming toolkit, was still too reliant on the XView toolkit.  This
  53.  * error no longer exists.
  54.  * Also, minor change to PrintDiagnostics() function; it no longer
  55.  * explicitly terminates with a "\n"; the caller must decide that a
  56.  * "\n" is wanted at the end of the string.
  57.  * 
  58.  * Revision 1.10  92/06/16  23:49:15  drapeau
  59.  * Made a number of changes:
  60.  * * Added support for the Sony CVD1000 (aka "Vdeck") device.
  61.  * * Added 'SetAsynchReadFunction' so as to allow the use of generic toolkit
  62.  *   notify functions for file reads.  This is the first step toward making
  63.  *   the VideoObject toolkit-neutral.
  64.  * 
  65.  * Revision 1.0  91/11/15  17:38:28  collab
  66.  * Initial revision
  67.  * 
  68.  * Revision 0.18  91/09/29  16:12:47  lim
  69.  * Put in all drivers.
  70.  * Added DisplayChoice.
  71.  * 
  72.  * Revision 0.17  91/09/24  22:01:29  lim
  73.  * 1. Used relative filename for driver header file.
  74.  * 
  75.  * Revision 0.16  91/08/24  18:00:57  lim
  76.  * Implemented PrintDiagnostics.
  77.  * 
  78.  * Revision 0.15  91/08/23  17:24:48  lim
  79.  * Included NECDriver.h
  80.  * Clear Marker has been removed as one of the video
  81.  * object functions.
  82.  * 
  83.  * Revision 0.14  91/08/21  10:52:54  lim
  84.  * Added second parameter to DevInit(serialPort).
  85.  * 
  86.  * Revision 0.13  91/08/17  20:45:50  lim
  87.  * 1. Configuration no longer has field for 'interruptibleSegmentPlay'.
  88.  * 2. NECInterrupt becomes NECClearMarker.
  89.  * 
  90.  * Revision 0.12  91/08/15  13:04:51  lim
  91.  * *** empty log message ***
  92.  * 
  93.  * Revision 0.11  91/08/09  11:05:29  lim
  94.  * Moved 'NECDriver.h' from 'vcrEdit.h'
  95.  * 
  96.  * Revision 0.10  91/08/08  17:32:34  lim
  97.  * Initial revision.
  98.  * 
  99.  * Revision 0.11  91/08/07  13:33:39  lim
  100.  * 1. DevInit() now returns pointer to VideoObject.
  101.  * 2. Added instance pointer, "theObject" to all public function calls.
  102.  * 3. DisplayError() is added so that device drivers can call it to 
  103.  * display error messages.
  104.  * 
  105.  * Revision 0.10  91/08/02  12:45:00  lim
  106.  * Initial revision.
  107.  *  */
  108.  
  109. /* WRITING NEW APPLICATION...
  110.  * 1. Replace the header file below with the header file for your own application.
  111.  */
  112.  
  113. #include "VideoEdit.h"
  114. #include <Pioneer4200Driver.h>
  115. #include <PanasonicOptDriver.h>
  116. #include <Pioneer6000Driver.h>
  117. #include <Sony1550Driver.h>
  118. #include <NECDriver.h>
  119. #include <CVD1000Driver.h>
  120.  
  121. /* ADDING NEW DRIVERS...
  122.  * 1. Add name of player to the array below.
  123.  * 2. Increment 'numDevices'.
  124.  */
  125.  
  126. char allDevices[MaxDevices][MaxNameLength]= 
  127. {
  128.   "Pioneer4200",
  129.   "Pioneer6000",
  130.   "Panasonic2026",
  131.   "Sony1550",
  132.   "NEC",
  133.   "CVD1000"
  134.   }
  135. ;
  136. int numDevices = 6;
  137.  
  138.  
  139. /* INCLUDE VIDEO OBJECTS HERE */
  140.  
  141.  
  142. /* Video Object for Pioneer4200 */
  143.  
  144. static Config Pioneer4200Config = 
  145. {
  146.   "Pioneer4200",
  147.   "/dev/ttya",
  148.   4800,
  149.   13,
  150.   8,
  151.   NoParity,
  152.   No,
  153.   No,
  154.   120,
  155.   -1
  156.   }
  157. ;
  158.  
  159. static VideoObject Pioneer4200Obj = 
  160. {
  161.   &Pioneer4200Config,
  162.   Pioneer4200Play,
  163.   Pioneer4200PlayFromTo,
  164.   Pioneer4200FastForward,
  165.   Pioneer4200Reverse,
  166.   Pioneer4200CalcSpeed,
  167.   Pioneer4200PlayAtSpeedDir,
  168.   Pioneer4200Step,
  169.   Pioneer4200Still,
  170.   Pioneer4200Stop,
  171.   Pioneer4200SetDefaults,
  172.   Pioneer4200SetAudio,
  173.   Pioneer4200SetVideo,
  174.   Pioneer4200SetAddMode,
  175.   Pioneer4200SetAddressDisplay,
  176.   Pioneer4200Eject,
  177.   Pioneer4200Power,
  178.   Pioneer4200QueryFrame,
  179.   Pioneer4200QueryChapter,
  180.   Pioneer4200QueryAudio,
  181.   Pioneer4200QueryVideo,
  182.   Pioneer4200QueryMedium,
  183.   Pioneer4200QueryStatus, 
  184.   Pioneer4200Ping,
  185.   NULL,
  186.   NULL
  187.   }
  188. ;
  189.  
  190. /* Video Object for CVD1000 */
  191.  
  192. static Config CVD1000Config = 
  193. {
  194.   "CVD1000",
  195.   "/dev/ttya",
  196.   9600,
  197.   -1,
  198.   8,
  199.   NoParity,
  200.   No,
  201.   No,
  202.   60,
  203.   -1
  204.   }
  205. ;
  206.  
  207. static VideoObject CVD1000Obj = 
  208. {
  209.   &CVD1000Config,
  210.   CVD1000Play,
  211.   CVD1000PlayFromTo,
  212.   CVD1000FastForward,
  213.   CVD1000Reverse,
  214.   CVD1000CalcSpeed,
  215.   CVD1000PlayAtSpeedDir,
  216.   CVD1000Step,
  217.   CVD1000Still,
  218.   CVD1000Stop,
  219.   CVD1000SetDefaults,
  220.   CVD1000SetAudio,
  221.   CVD1000SetVideo,
  222.   CVD1000SetAddMode,
  223.   CVD1000SetAddressDisplay,
  224.   CVD1000Eject,
  225.   CVD1000Power,
  226.   CVD1000QueryFrame,
  227.   CVD1000QueryChapter,
  228.   CVD1000QueryAudio,
  229.   CVD1000QueryVideo,
  230.   CVD1000QueryMedium,
  231.   CVD1000QueryStatus, 
  232.   CVD1000Ping,
  233.   CVD1000Record,
  234.   CVD1000RecordFromTo
  235.   }
  236. ;
  237.  
  238. /* Video Object for PanasonicOpticalDiskPlayer */
  239.  
  240. static Config PanasonicOptConfig = 
  241. {
  242.   "Panasonic2026",
  243.   "/dev/ttyb",
  244.   1200,
  245.   13,
  246.   8,
  247.   Even,
  248.   Yes,
  249.   Yes,
  250.   300, 
  251.   -1
  252.   }
  253. ;
  254.  
  255. static VideoObject PanasonicOptObj = 
  256. {
  257.   &PanasonicOptConfig,
  258.   PanasonicOptPlay,
  259.   PanasonicOptPlayFromTo,
  260.   PanasonicOptFastForward,
  261.   PanasonicOptReverse,
  262.   PanasonicOptCalcSpeed,
  263.   PanasonicOptPlayAtSpeedDir,
  264.   PanasonicOptStep,
  265.   PanasonicOptStill,
  266.   PanasonicOptStop,                            
  267.   PanasonicOptSetDefaults,                        
  268.   PanasonicOptSetAudio,                        
  269.   PanasonicOptSetVideo,
  270.   NULL,
  271.   PanasonicOptSetAddressDisplay,
  272.   PanasonicOptEject,
  273.   NULL,
  274.   PanasonicOptQueryFrame,
  275.   NULL,
  276.   NULL,
  277.   NULL,
  278.   PanasonicOptQueryMedium,
  279.   PanasonicOptQueryStatus,
  280.   PanasonicOptPing,
  281.   NULL,
  282.   NULL
  283.   }
  284. ;
  285.  
  286. /* Video Object for Pioneer6000 */
  287.  
  288. static Config Pioneer6000Config = 
  289. {
  290.   "Pioneer6000",
  291.   "/dev/ttyb",
  292.   1200,
  293.   13,
  294.   8,
  295.   Even,
  296.   Yes,
  297.   Yes,
  298.   90,
  299.   -1
  300.   }
  301. ;
  302.  
  303. static VideoObject Pioneer6000Obj = 
  304. {
  305.   &Pioneer6000Config,
  306.   Pioneer6000Play,
  307.   Pioneer6000PlayFromTo,
  308.   Pioneer6000FastForward,
  309.   Pioneer6000Reverse,
  310.   Pioneer6000CalcSpeed,
  311.   Pioneer6000PlayAtSpeedDir,
  312.   Pioneer6000Step,
  313.   Pioneer6000Still,
  314.   Pioneer6000Stop,                            
  315.   Pioneer6000SetDefaults,                        
  316.   Pioneer6000SetAudio,                        
  317.   Pioneer6000SetVideo,
  318.   NULL,
  319.   Pioneer6000SetAddressDisplay,
  320.   Pioneer6000Eject,
  321.   NULL,
  322.   Pioneer6000QueryFrame,
  323.   NULL,
  324.   NULL,
  325.   NULL,
  326.   NULL,
  327.   Pioneer6000QueryStatus,
  328.   Pioneer6000Ping,
  329.   NULL,
  330.   NULL
  331.   }
  332. ;
  333.  
  334. /* Video Object for Sony1550 */
  335.  
  336. static Config Sony1550Config = 
  337. {
  338.   "Sony1550",
  339.   "/dev/ttyb",
  340.   2400,
  341.   -1,
  342.   8,
  343.   Even,
  344.   Yes,
  345.   Yes,
  346.   90,
  347.   -1
  348.   }
  349. ;
  350.  
  351. static VideoObject Sony1550Obj = 
  352. {
  353.   &Sony1550Config,
  354.   Sony1550Play,
  355.   Sony1550PlayFromTo,
  356.   Sony1550FastForward,
  357.   Sony1550Reverse,
  358.   Sony1550CalcSpeed,
  359.   Sony1550PlayAtSpeedDir,
  360.   Sony1550Step,
  361.   Sony1550Still,
  362.   Sony1550Stop,                            
  363.   Sony1550SetDefaults,                        
  364.   Sony1550SetAudio,                        
  365.   Sony1550SetVideo,
  366.   Sony1550SetAddMode,
  367.   Sony1550SetAddressDisplay,
  368.   Sony1550Eject,
  369.   NULL,
  370.   Sony1550QueryFrame,
  371.   Sony1550QueryChapter,
  372.   NULL,
  373.   NULL,
  374.   Sony1550QueryMedium,
  375.   Sony1550QueryStatus,
  376.   Sony1550Ping,
  377.   NULL,
  378.   NULL
  379.   }
  380. ;
  381.  
  382.  
  383. /* Video Object for NEC PC VCR */
  384.  
  385. static Config NECConfig = 
  386. {
  387.   "NEC",
  388.   "/dev/ttya",
  389.   1200,
  390.   13,
  391.   8,
  392.   NoParity,
  393.   No,
  394.   No,
  395.   270,
  396.   -1
  397.   }
  398. ;
  399.  
  400. static VideoObject NECObj = 
  401. {
  402.   &NECConfig,
  403.   NECPlay,
  404.   NECPlayFromTo,
  405.   NECFastForward,
  406.   NECReverse,
  407.   NECCalcSpeed,
  408.   NECPlayAtSpeedDir,
  409.   NECStep,
  410.   NECStill,
  411.   NECStop,
  412.   NECSetDefaults,
  413.   NECSetAudio,
  414.   NECSetVideo,
  415.   NECSetAddressingMode,
  416.   NULL,
  417.   NECEject,
  418.   NECPower,
  419.   NECQueryFrame,
  420.   NULL,
  421.   NECQueryAudio,
  422.   NECQueryVideo,
  423.   NECReadHeader,
  424.   NECQueryStatus,
  425.   NECPing,
  426.   NECRecord,
  427.   NECRecordFromTo
  428.   }
  429. ;
  430.  
  431.  
  432. /* DevInit builds the video object for the appropriate ...
  433.  * ... device and sets up the serial line.  It returns the ...
  434.  * ... pointer to the video object.
  435.  */
  436.  
  437. VideoObject*
  438.   DevInit(char*    deviceName,
  439.       char* serialPort)
  440. {
  441.   VideoObject* myVideo;
  442.   
  443.   /* ADDING NEW DRIVERS
  444.      ... Add statements for new device here, as another else-if statement */
  445.   
  446.   if (strcmp(deviceName, "Pioneer4200") == 0)                /* Set the video object to the appropriate variable */
  447.     myVideo = BuildVideoObject(&Pioneer4200Obj);
  448.   else if (strcmp(deviceName, "Sony1550") == 0)
  449.     myVideo = BuildVideoObject(&Sony1550Obj);
  450.   else if (strcmp(deviceName, "Panasonic2026") == 0)
  451.     myVideo = BuildVideoObject(&PanasonicOptObj);
  452.   else if (strcmp(deviceName, "Pioneer6000") == 0)
  453.     myVideo = BuildVideoObject(&Pioneer6000Obj);
  454.   else if (strcmp(deviceName, "NEC") == 0)
  455.     myVideo = BuildVideoObject(&NECObj);                
  456.   else if (strcmp(deviceName, "CVD1000") == 0)
  457.     myVideo = BuildVideoObject(&CVD1000Obj);                
  458.   
  459.   if (PlayerVerified(myVideo, serialPort) != -1)            /* Sets up serial line for communicating with the device */
  460.     if (SetSerialLine(myVideo->DevConfig, serialPort))
  461.       return myVideo;
  462.     else
  463.       return NULL;
  464.   else
  465.     return NULL;
  466. }                                    /* end function DevInit */
  467.  
  468.  
  469.  
  470. /* WRITING NEW APPLICATIONS... 
  471.  * Optional : Replace the code within DisplayError() if a different 
  472.  * error notification function is desired.
  473.  *
  474.  * DO NOT remove the function DisplayError().
  475.  * 
  476.  * DisplayError() is useful in displaying errors other than those dealing
  477.  * with the device.
  478.  */
  479.  
  480. /* WRITING NEW DRIVERS...
  481.  * IMPORTANT : 
  482.  * Video drivers should be written such that any detectable error
  483.  * is decoded into English and placed into at most 2 strings. Then the
  484.  * driver is responsible for calling DisplayError() which displays the
  485.  * errors appropriately to the user.
  486.  */
  487.  
  488. /* DisplayError takes 2 strings that explain the error condition encountered.
  489.  */
  490. void
  491. DisplayError(char* errorMsg1,
  492.          char* errorMsg2)
  493. {
  494.   notice_prompt(VideoEdit_window1->window1, NULL,
  495.         NOTICE_MESSAGE_STRINGS,
  496.         errorMsg1,
  497.         errorMsg2,
  498.         NULL,
  499.         NOTICE_BUTTON,    "OK", 100,
  500.         NULL);
  501. }
  502.  
  503.  
  504. /* Display choice message */
  505. int
  506. DisplayChoice(char* msg1,
  507.           char* msg2,
  508.           char* r1,
  509.           char* r2)
  510. {
  511.   int result = notice_prompt(VideoEdit_window1->window1, NULL,
  512.                  NOTICE_MESSAGE_STRINGS,
  513.                  msg1, msg2,
  514.                  NULL,
  515.                  NOTICE_BUTTON_YES, r1,
  516.                  NOTICE_BUTTON_NO, r2, 
  517.                  NULL);
  518.   return result;
  519.   
  520. }
  521.  
  522.  
  523. void
  524. PrintDiagnostics(char* msg)
  525. {
  526.   if (diagMode == Yes)
  527.     fprintf(stderr, "%s", msg);
  528. }
  529.  
  530.  
  531. static int (*callbackProc)(int);                    /* Pointer to function called when asynch read is needed */
  532.  
  533.     
  534. Notify_value MyAsyncCallback(Notify_client    client,
  535.                  int        fd)
  536. {
  537.   return((*callbackProc) (fd));
  538. }                                    /* end function MyAsyncCallback */
  539.  
  540.  
  541.  
  542. void 
  543. SetAsynchReadFunction(int    (*callback)(int),
  544.               int    fd,
  545.               int    onOrOff)
  546. {
  547.   /* Code here would use the callback function provided to be
  548.      called when input occurred on the file descriptor of "theObject".
  549.      For XView, the code might be this:
  550.      */
  551.   callbackProc = callback;
  552.   
  553.   if (onOrOff == FeatureOn)
  554.     notify_set_input_func((Notify_client) AppClient, 
  555.               MyAsyncCallback, fd);
  556.   else
  557.     notify_set_input_func((Notify_client) AppClient,
  558.               NOTIFY_FUNC_NULL, fd);            /* Turn off automatic read */
  559. }                                    /* end function SetAsynchReadFunction */
  560.